<?php
defined('IN_ADMIN') or exit('No permission resources.');
$show_validator = $show_scroll = $show_dialog = 1;
include $this->admin_tpl('header', 'admin');

?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<h3 style="padding-left: 20px;padding-top: 10px">
	<?php echo $course_info['name']?>——关联人才
	<a href="?m=course_nsr&c=manage&a=init" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
</h3>

<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		<a href="?m=course_nsr&c=talent&a=init&course_id=<?php echo $course_info['id']?>&talent_type=2" <?php if(ROUTE_A=="init"&&$talent_type==2){ ?>   class="on"<?php } ?><em>学员</em></a>
		<span>|</span>
		<a href="?m=course_nsr&c=talent&a=init&course_id=<?php echo $course_info['id']?>&talent_type=7" <?php if(ROUTE_A=="init"&&$talent_type==7){ ?>   class="on"<?php } ?><em>导师</em></a>
	</div>
</div>
<div class="pad-lr-10">

	<div id="searchid" style="">
		<form name="searchform" action="" method="get" >
			<input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
			<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
			<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">
			<input type="hidden" value="<?php echo $talent_type;?>" name="talent_type">
			<input type="hidden" value="1" name="search">
			<input type="hidden" value="<?=$course_id?>" name="course_id">
			<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
			<table width="100%" cellspacing="0" class="search-form">
				<tbody>
				<tr>
					<td>

						<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showAdd()" ><em>添加<?= $btn_info?></em></button>
						<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showSelect()" ><em>选择<?= $btn_info?></em></button>
						<span style="clear: both"></span>
						<script>
							function showAdd(){
								window.top.art.dialog({
										id: 'add',
										iframe: '?m=course_nsr&c=talent&a=add&course_id=<?=$course_id?>&talent_type=<?=$talent_type?>&flag=contest',
										title: '添加<?= $btn_info?>',
										width: '900',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'add'
										}).data.iframe;
										var form = d.document.getElementById('dosubmit');
										form.click();
										return false;
									},
									function() {
										window.top.art.dialog({
											id: 'add'
										}).close()
									});
							}
							function  showSelect(){
								window.top.art.dialog({
										id: 'select',
										iframe: '?m=course_nsr&c=talent&a=bindView&course_id=<?=$course_id?>&talent_type=<?=$talent_type?>',
										title: '选择<?= $btn_info?>',
										width: '900',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'select'
										}).data.iframe;
										var relation = d.document.getElementById('relation');


										if(relation.value!=""){
											$.ajax({
												type:"get",
												url:"?m=course_nsr&c=talent&a=bindAction&talent_type=<?=$talent_type?>'&course_id=<?=$course_id?>&relation="+relation.value+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
												dataType: "json",
												success:function(data){
													if(data['status']){
														window.top.art.dialog({
															id: 'select'
														}).close()
														window.location.reload();
													}else{
														alert(data['msg']);
														return false;
													}
												}
											})
										}else{
											return true;
										}

									},
									function() {
										window.top.art.dialog({
											id: 'select'
										}).close()
									});
							}
						</script>


						<div class="explain-col">
							<?php if($talent_type == 7){?>
							 人才类别：
							<select name="talent_type_key">
								<option value="">请选择</option>
								<option value="is_moter" <?php if($talent_key == 'is_moter'){echo 'selected';}?>>模特</option>
								<option value="is_signed_model" <?php if($talent_key == 'is_signed_model'){echo 'selected';}?>>签约模特</option>
								<option value="is_hot" <?php if($talent_key == 'is_hot'){echo 'selected';}?>>网红</option>
								<option value="is_guest"<?php if($talent_key == 'is_guest'){echo 'selected';}?>>嘉宾</option>
								<option value="is_judge"<?php if($talent_key == 'is_judge'){echo 'selected';}?>>评委</option>
								<option value="is_star"<?php if($talent_key == 'is_star'){echo 'selected';}?>>明星</option>
								<option value="is_mentor"<?php if($talent_key == 'is_mentor'){echo 'selected';}?>>导师</option>
							</select>
							<?php }?>
							<?php echo L('realname');?>：<input name="title" type="text" value="<?php echo $_GET['title']?>" class="input-text" />
							<input type="submit" name="search" class="button" value="<?php echo L('search');?>" />
						</div>
					</td>
				</tr>
				</tbody>
			</table>
		</form>
	</div>

	<form name="myform" id="myform" action="" method="post" >
		<div class="table-list">
			<table width="100%">
				<thead>
				<tr>
					<th width="16"><input type="checkbox" value="" id="check_box" onclick="selectall('ids[]');"></th>
					<th width="57"><?php echo L('realname');?></th>
					<th><?php echo L('nickname');?></th>
					<th><?php echo L('enname')?></th>
					<th><?php echo L('gender');?></th>
					<th><?php echo L('image_square');?></th>
					<th><?php echo L('author');?></th>
					<th><?php echo "绑定者";?></th>
					<th width="200"><?php echo L('operations_manage');?></th>
				</tr>
				</thead>
				<tbody>
				<?php
				if(!empty($talent_info)){
					if(is_array($talent_info)) {
	
						foreach ($talent_info as $k=>$r) {
							?>
							<tr>
								<td align="center"><input class="inputcheckbox " name="ids[]" value="<?php echo $r['id'];?>" type="checkbox"></td>
								<td align='center'><?php echo $r['real_name']?></td>
								<td align='center' ><?php if(!empty($r['nickname'])){echo $r['nickname'];}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
								<td align='center' ><?php if(!empty($r['en_name'])){echo $r['en_name'];}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
								<td align='center'><?php if($r['gender'] == 1){echo '男';}elseif($r['gender'] == 2){echo '女';}elseif($r['gender'] == 3){echo '保密';}?></td>
								<td align='center'><?php if(!empty($r['image_square'])){echo '<img src="'.$r['image_square'].'" height="80px">';}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
								<td align='center'><?php echo $adminInfo[$r['updated_by']]?></td>
								<td align='center'><?php echo $adminInfo[$r['supdated_by']]?></td>
								<td align='center'><a href="?m=course_nsr&c=talent&a=del&id=<?php echo $r['id']?>" onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($r['title'])))?>')"><?php echo L('delete_bind')?></a></td>
	
							</tr>
						<?php }
					}
				}else{
				?>
					<tr><td colspan='9' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>
				<?php }?>
				</tbody>
			</table>
			<div class="btn"><label for="check_box"><?php echo L('selected_all');?>/<?php echo L('cancel');?></label>
				<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
				<input type="button" class="button" value="<?php echo L('delete');?>" onclick="myform.action='?m=course_nsr&c=talent&a=deleteAll&dosubmit=1&steps=<?php echo $steps;?>';return confirm_delete()"/>
			</div>
			<div id="pages"><?php echo $pages;?></div>
		</div>
	</form>
</div>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script type="text/javascript">

	function confirm_delete(){
		if(confirm('<?php if($talent_type == 2){echo L('confirm_delete_student_bind', array('message' => L('selected')));}elseif($source_type == 7){echo L('confirm_delete_mentor_bind', array('message' => L('selected')));}?>')) $('#myform').submit();
	}

	function changeTop(obj){
		var id=$(obj).attr("data-id");
		var top=$(obj).attr("data-top");
		//top为现在状态
		var msg="";
		if(top==1){
			top=0;
			msg="否";

		}else{
			top=1;
			msg="是";
		}

		$.ajax({
			type:"get",
			url:"?m=resource_asso&c=manage&a=top&id="+id+"&is_top="+top+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
			dataType: "json",
			success:function(data){
				if(data['status']){
						$(obj).text(msg);
					    $(obj).attr("data-top",top);
				}else{
					alert(data['msg']);
					return false;
				}
			}
		})
	}
</script>
</body>
</html>